package com.ruimei.service.impl;

import com.ruimei.entitys.Task;
import com.ruimei.entitys.Teacher;
import com.ruimei.mapper.TaskMapper;
import com.ruimei.service.ITaskService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class ITaskServiceImpl
  implements ITaskService
{
  @Resource
  private TaskMapper task;
  
  public boolean putTask(Task entity, Teacher teacher)
  {
    entity.setTeacherId(teacher.getId());
    entity.setTeacherName(teacher.getFullName());
    if (this.task.insertTask(entity) >= 1) {
      return true;
    }
    return false;
  }
  
  public Map<String, Object> taskView(String id, String taskId)
  {
    Map<String, Object> map = new HashMap();
    map.put("data", this.task.selectTask(id, taskId));
    map.put("message", "success");
    map.put("status", Boolean.valueOf(true));
    return map;
  }
  
  public List<String> selectSubject(String classId, String teacherId)
  {
    return this.task.selectSubject(classId, teacherId);
  }
  
  public Map<String, Object> getSubjectByTeacherId(String id)
  {
    Map<String, Object> map = new HashMap();
    map.put("status", Boolean.valueOf(true));
    map.put("data", this.task.selectSubjectName(id));
    
    return map;
  }

  @Override
  public Map<String, Object> deletetask(Task task, String teacherId) {
    Map<String, Object> map = new HashMap();
    Map<String, Object> data = new HashMap();
    if(teacherId.equals(task.getTeacherId())){
      Integer i = this.task.deleteTask(task);
      if(i == 1) {
        data.put("msg", "删除成功");
        data.put("status", true);
        map.put("status", true);
        map.put("data", data);
      }else{
        data.put("msg", "删除失败");
        data.put("status", false);
        map.put("status", true);
        map.put("data", data);
      }
    }else {
      data.put("msg","作业只能发布老师删除");
      data.put("status", false);
      map.put("status", true);
      map.put("data", data);
    }
    return map;
  }
}


/* Location:              E:\360MoveData\Users\admin\Desktop\teacher_wap-0.0.1-SNAPSHOT.jar!\BOOT-INF\classes\com\ruimei\service\impl\ITaskServiceImpl.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       0.7.1
 */